//
//  CommunityCell.m
//  Qyer
//
//  Created by dllo on 15/10/19.
//  Copyright (c) 2015年 GF. All rights reserved.
//

#import "CommunityCell.h"

@implementation CommunityCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.photo = [[UIImageView alloc] initWithFrame:CRM(0, 10 * HEIGHT, 50 * WIDTH, 50 * WIDTH)];
        [self.contentView addSubview:_photo];
        
        self.title = [[UILabel alloc] init];
        
        _title.font = [UIFont systemFontOfSize:17];
        [self.contentView addSubview:_title];
        
        self.postCount = [[UILabel alloc] init];
        [self.contentView addSubview:_postCount];
        self.postCount.textColor = [UIColor lightGrayColor];
        self.postCount.font = [UIFont systemFontOfSize:15.];
    }
    return self;
}

- (void)setCellWithModel:(CommunityModel *)model {
    [_photo sd_setImageWithURL:[NSURL URLWithString:model.photo] placeholderImage:[UIImage imageNamed:@"zw"]];
    
    _title.numberOfLines = 0;
    CGFloat height = [StringWithHeight HeightWithText:model.name width:self.frame.size.width - self.photo.frame.size.width - 15 * WIDTH font:[UIFont systemFontOfSize:17]];
    _title.frame = CRM(self.photo.frame.size.width + 10 * WIDTH, 10 * HEIGHT, self.frame.size.width - self.photo.frame.size.width - 15 * WIDTH, height);
    _title.text = model.name;
    
    _postCount.frame = CRM(self.photo.frame.size.width + 10 * WIDTH, height + 15 * HEIGHT, _title.frame.size.width, 25 * HEIGHT);
    _postCount.text = [NSString stringWithFormat:@"%@个帖子", model.total_threads];
    
}
- (void)setCellWithForum:(Forum *)model {
    [_photo sd_setImageWithURL:[NSURL URLWithString:model.photo] placeholderImage:[UIImage imageNamed:@"zw"]];
    
    _title.numberOfLines = 0;
    CGFloat height = [StringWithHeight HeightWithText:model.name width:self.frame.size.width - self.photo.frame.size.width - 15 * WIDTH font:[UIFont systemFontOfSize:17]];
    _title.frame = CRM(self.photo.frame.size.width + 10 * WIDTH, 10 * HEIGHT, self.frame.size.width - self.photo.frame.size.width - 15 * WIDTH, height);
    _title.text = model.name;
    
    _postCount.frame = CRM(self.photo.frame.size.width + 10 * WIDTH, height + 15 * HEIGHT, _title.frame.size.width, 25 * HEIGHT);
    _postCount.text = [NSString stringWithFormat:@"%@个帖子", model.total_threads];
}

@end
